#ifndef CONFIGMODEL_H
#define CONFIGMODEL_H

#include <QAbstractListModel>
#include "configmanager.h"
#include "logger.h"  // 确保引入日志系统的头文件

class ConfigModel : public QAbstractListModel {
    Q_OBJECT

public:
    explicit ConfigModel(QObject *parent = nullptr);
    ~ConfigModel() override;

    enum RoleNames {
        KeyRole = Qt::UserRole + 1,
        ValueRole,
        TypeRole,
        DescriptionRole,
        IOTypeRole,
        NameRole,
        ValueMaxRole,
        ValueMinRole,
        QmlstyleRole,
        OptionRole,
    };

    // QAbstractListModel 的必要函数
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    QHash<int, QByteArray> roleNames() const override;

    // 加载和保存数据的方法
    void loadData(const QString& category);
    void saveData();



protected:
    QString currentCategory;
    QVector<QVariantMap> items;
};

#endif // CONFIGMODEL_H
